import { useState, useRef } from 'react'

export default () => {
  const [num, setNum] = useState(0)
  // let count = useRef(0) // 可以给普通值进行记忆操作
  const handleClick = () => {
    // let count = 0 //不具备记忆功能的
    // console.log(count++)
    // count.current++
    // console.log(count.current)
    setNum(num + 1)
    console.log(num)
  }
  return (
    <div>
      <button onClick={handleClick}>点击</button>
    </div>
  )
}
